﻿
namespace Mitosoft.Definitions.Data
{
  /// <summary>
  /// Method called whenever an instance is requested.
  /// This can be used to generate view models.
  /// </summary>
  /// <param name="dataBlockItem">Represents the data from which a new instance can be generated.</param>
  /// <param name="sourceIndex">Represents the source index.</param>
  /// <returns>Generated instance.</returns>
  public delegate IGenericDataBlockItem<string> CreateDataBlockItemInstanceDelegate(
    IGenericDataBlockItem<string> dataBlockItem, int sourceIndex);

  public interface ICacheableDataBlockProvider<out D, V> : IDataBlockProvider<D,V> where D : IGenericDataBlockItem<V>
  {
    /// <summary>
    /// Occurs when a new instance is requested.
    /// </summary>
    event CreateDataBlockItemInstanceDelegate DataBlockItemInstanceRequest;
  }
}
